package org.hxyjs.controller;

import org.hxyjs.dto.DTO;
import org.hxyjs.entity.ActCosttyperecord;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.ActCosttyperecordService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller //@Controller注解是用spring容器生成 对象 默认对象名 actCosttyperecordController
@RequestMapping("/actCosttyperecordController") //@RequestMapping 用户请求查找该资源使用的名字 网名 默认  /actCosttyperecordController
public class ActCosttyperecordController {
	@Resource
    ActCosttyperecordService actCosttyperecordService;
	@RequestMapping("/getAllActCosttyperecord")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<ActCosttyperecord> getAllActCosttyperecord() throws Exception{
    	System.out.println("查询活动消费券记录");
    	return actCosttyperecordService.getAllActCosttyperecords();
    }
	@RequestMapping("/addActCosttyperecord")
	@ResponseBody
	public DTO<ActCosttyperecord> addActCosttyperecord( @RequestBody ActCosttyperecord actCosttyperecord) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加活动消费券记录成功");
		return actCosttyperecordService.addActCosttyperecord(actCosttyperecord);
	}

	@RequestMapping("/deleteActCosttyperecord/{afcno}")
	@ResponseBody
    public DTO<ActCosttyperecord> deleteActCosttyperecord(@PathVariable("afcno") String afcno) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(afcno+"删除活动消费券记录成功");
    	return actCosttyperecordService.deleteActCosttyperecord(afcno);
    }



	@RequestMapping("/getActCosttyperecordByAfcno/{afcno}")
	@ResponseBody
	public DTO<ActCosttyperecord> getActCosttyperecordByAfcno(@PathVariable("afcno") String afcno) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println(afcno+"根据主键查询活动消费券记录成功");
		return actCosttyperecordService.getActCosttyperecordByAfcno(afcno);
	}

	@RequestMapping("/updateActCosttyperecord")
	@ResponseBody
	public DTO<ActCosttyperecord> updateActCosttyperecord(@RequestBody ActCosttyperecord actCosttyperecord) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改活动消费券记录成功");
		System.out.println(actCosttyperecord);
		return actCosttyperecordService.updateActCosttyperecord(actCosttyperecord);
	}

	@RequestMapping("/getActCosttyperecordByPage")
	@ResponseBody
	public DTO<ActCosttyperecord> getActCosttyperecordByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页查询活动消费券记录成功");
		return actCosttyperecordService.getActCosttyperecordByPage(pageInfo);
	}

}
